<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!-- <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" /> -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/backstage/css/font.css">
    <link rel="stylesheet" href="/backstage/css/xadmin.css">
    <!-- <link rel="stylesheet" href="http://unpkg.com/iview/dist/styles/iview.css"> -->
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
     li{
        float:left;
        margin:30px 15px;
      }
      #file_list div{
        width:200px;
        height: 100px;
        margin-top:5px;
        text-align: center;
      }
      #file_list img,video{
        /* width:150px; */
        max-width: 100%;
        height: 100%;
      }

      video{
        width:100%;
      }
      audio{
        width:100%;
      }
      #file_list p{
        text-align: center;
      }
      </style>
  </head>
  
  <body >
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">附件管理</a>
        <a href="{:url('folder_list')}?folder_type={$type}">{:config('type.resource_type')[$type]}管理</a>
        <a>
          <cite>{:config('type.resource_type')[$type]}列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body" id='role'>
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
          <input class="layui-input" placeholder="开始日" name="start" id="start" >
          <input class="layui-input" placeholder="截止日" name="end" id="end" >
          <input type="text" name="seach_text"  placeholder="输入名称搜索" id='seach_text' class="layui-input" >
          <button class="layui-btn"  lay-submit="" lay-filter="sreach" type="button" @click="seachData"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <div>
       <a href="{:url('folder_list')}?folder_type={$type}"> <button class="layui-btn"><i class="layui-icon layui-icon-return"></i>返回上一层</button></a>
        <button class="layui-btn layui-btn-danger" onclick="deleteImage()"><i class="layui-icon"></i>选中删除</button>
        <button class="layui-btn" onclick="showUploadImage('{$folder_id}','{$type}')"><i class="layui-icon layui-icon-upload-drag">&#xe67c;</i>上传{:config('type.resource_type')[$type]}</button>
        <!-- <button class="layui-btn" onclick="showUploadImage('{$folder_id}',1)"><i class="layui-icon layui-icon-upload-drag">&#xe67c;</i>批量上传</button> -->
        <span class="x-right" style="line-height:40px">共有数据：{{pageData.count}} 条</span>
      </div>
      <hr>
      <div id='file_list' >
        <ul>
          <li v-for="(item,index) in fileList">
              <div style='display:inline' class="layui-unselect layui-form-checkbox" onclick="checkThis(this)" lay-skin="primary" :data-id='item.id'><i class="layui-icon">&#xe605;</i></div>            
              
              <div>
                  <img v-if="item.type==1" :src="filePath+item.file_path" alt="" id='showImg' onclick="showBigImg(this)">
                  <video v-if="item.type==3" :src="filePath+item.file_path" controls ></video>
                  <audio v-if="item.type==2" :src="filePath+item.file_path" controls ></audio>
                  <p>{{item.file_name}}</p>
                  <p style="color:#ccc">{{item.create_time}}</p>
              </div>
          </li>
        </ul>
      </div>
    
      <div style="clear:both;display:block;text-align:center;padding-top:50px;">
       
        <div v-if="fileList.length" id="page" ></div>
        <div v-else style="color:#ccc"  >暂无数据</div>
      </div>
    </div>

    <!-- import iView -->
  
  </body>
  <script type="text/javascript" src="/js/jquery.js"></script>
  <script type="text/javascript" src="/js/vue.js"></script>
  <!-- <script src="http://unpkg.com/iview/dist/iview.min.js"></script>     -->
  <script type="text/javascript" src="/backstage/js/xadmin.js?v=2"></script>
  <script type="text/javascript" src="/backstage/lib/layui/layui.js" ></script>
  
  <script>

    var app = new Vue({
      el:'#role',
      data: {
          filePath:"{:config('api.oss_img_path')}",
          fileList:[],
          pageData:{
              page:1,
              count:10,
              pageSize:10,
              start: '',
              end: '',
              seach_text: '',
              folder_id:'{$folder_id}',
              type:'{$type}'
        }
      },
      methods:{
        //获取列表
        getListData: function () {

          var that = this;
          $.get('{:url("file_list")}',that.pageData,function(res){
            if(res.code==200){
              var list = res.fileList
              for(index in list){
               if(list[index].file_name.length>18)
               list[index].file_name =  list[index].file_name.substring(0,18)+'...';
              }
              that.fileList = res.fileList;
              that.pageData.page = res.pageData.page;
              that.pageData.count = res.pageData.count;
              that.pageData.pageSize = res.pageData.pageSize;
                if(res.pageData.page==1){
                    page(that.pageData);
                }
             
            }else{
              layer.msg(res.msg,{icon:5,time:1000});
            }
          },'json');
        },

        //分页
        page:function(){
          var that = this;
          setTimeout(function(){
              page(that.pageData);
          },100)
        },
        //删除
        image_delete:function(index,id){
          var that = this;
          layer.confirm('删除后不可恢复',{title:'谨慎操作！'},function(index){
            $.post('{:config(\'template.root_path\')}/resource/image_delete',{id:id},function(msg){
            if(msg.code==200){
              layer.msg('已删除!',{icon:1,time:1000});
              that.getListData();
            }else{
              layer.msg(res.msg,{icon:5,time:1000});
            }
          },'json')
         });
        },

        //搜索
        seachData:function(){
          this.pageData.end = $('#end').val();
          this.pageData.start = $('#start').val();
          this.pageData.seach_text = $('#seach_text').val();
          this.getListData();
          this.page();
        }
      },
      created: function () {
        this.getListData();
        var that = this;
//        setTimeout(function(){
//              that.page();
//          },100)
      }
    });

   layDate();

  </script>
</html>